/**
 * DataUtil.java
 * com.ebook.util
 * Copyright (c) 2013, 公司版权所有.
*/

package com.ebook.util;

/**
 * 工具类
 * @author    潘吉友
 * @Date	 2013-3-11 	 
 */
public class DataUtil {

	public static String objToStr(String s) {
		if(s == null || s == ""){
			return "";
		}
		else{
			return s.trim();
		}		
	}
	
	/**
	 * 随机生成6位字符串
	 * 字符串
	*/
	public static String randomCheckCode(){
		int length = 6;
		int num = 1;
		double random = Math.random();
		if (random < 0.1) {
			random = random + 0.1;
		}
		for (int i = 0; i < length; i++) {
			num = num * 10;
		}
		String password = ((int) ((random * num)) + "").trim();
		return password;
	}
	
	/**
	 * 核对两个字符串是否相等
	 * @param str1
	 * @param str2
	 * @return true:相等；false:不相等
	*/
	public static boolean checkString(String str1,String str2){
		if(str1==null || str1 == ""|| str2 ==null || str2==""){
			return false;
		}
		if(str1.equals(str2)){
			return true;
		}else{
			return false;
		}
	}
	
	public static void main(String[] args) {
		String t1 = "";
		String t2 = "pjyjpy";
		if(checkString(t1, t2)){
			System.out.println("==");
		}else{
			System.out.println("!=");
		}
	}
}

